﻿using JESAI.Authorize.Abstractions;
using JESAI.Authorize.Values;
using JESAI.Core.Listener;
using System.Threading.Tasks;

namespace JESAI.Authorize.Listener
{
    public class JESAIAuthorizeListener : IJESAIListener
    {
        private readonly IPermissionRepository _permissionRepository;

        public JESAIAuthorizeListener(IPermissionRepository permissionRepository)
        {
            _permissionRepository = permissionRepository;
        }

        public string ListenerName => "JESAI.Authorize";

        public async Task ExecuteAsync(string commandText)
        {
            if (!string.IsNullOrWhiteSpace(commandText) && commandText == NetworkCommandType.Reload.ToString())
                await _permissionRepository.Get();
        }
    }
}
